package org.inspiration.dudu.web.controller.message;

import lombok.RequiredArgsConstructor;
import org.inspiration.dudu.common.pojo.Result;
import org.inspiration.dudu.message.model.vo.SessionVO;
import org.inspiration.dudu.web.annotation.Loggable;
import org.inspiration.dudu.web.service.message.SessionFacadeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequiredArgsConstructor
@Loggable
@RequestMapping("/sessions")
public class SessionController {

    private final SessionFacadeService sessionFacadeService;

    @GetMapping
    public Result<List<SessionVO>> getSessions(@RequestParam("fromUserId") Long fromUserId,
                                               @RequestParam("pageNum") Integer pageNum,
                                               @RequestParam("pageSize") Integer pageSize) {
        List<SessionVO> list = sessionFacadeService.getSessions(fromUserId, pageNum, pageSize);
        return Result.success(list);
    }
}
